package com.qf.controller;

import com.alibaba.fastjson.JSON;
import com.qf.entity.GoodsType;
import com.qf.service.GoodsTypeService;
import com.qf.service.impl.GoodsTypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author 10202
 * @version V1.0
 * @Project xiaomi
 * @Package com.qf.controller
 * @Date 2023/4/14 9:35
 */
@WebServlet(urlPatterns = "/goodstypeservlet")
public class GoodsTypeServlet extends BaseServlet{
    public String goodstypelist(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
        GoodsTypeService goodsTypeService=new GoodsTypeServiceImpl();
        try {
            List<GoodsType> list=goodsTypeService.queryByLevels(1);

            String s = JSON.toJSONString(list);
            response.setContentType("application/json;charset=utf-8");
            response.getWriter().write(s);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }


}
